package com.bzy.common.exception;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.springframework.validation.Errors;
import org.springframework.validation.FieldError;

public class SpringValidException extends RuntimeException implements Serializable{
	
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 7216688089150616871L;
	private Errors erors;
	
	public SpringValidException(Errors erors) {
		super();
		this.erors = erors;
	}

	public Errors getErors() {
		return erors;
	}

	public void setErors(Errors erors) {
		this.erors = erors;
	}
	
	public List<String> getErrorMessages() {
		
		List<String> list = new ArrayList<String>();
		for (FieldError fe : this.getErors().getFieldErrors()) {
			list.add(fe.getDefaultMessage());
		}
		return list;
	}
}
